<template>
	<u-icon @tap="likeAdaptiveFun" :label="nowlikeCount" :name="isSelectData == 1?'thumb-up-fill':'thumb-up'" :color="isSelectData == 1?'#66a6ff':'#666666'" size="24" label-size="24" class="u-padding-right-30"></u-icon>
</template>

<script>
	import {
		likeAdaptive
	} from '@/yixu/api/network_square'
	export default {
		data() {
			return {
				nowlikeCount:0,
				isSelectData:0,
			}
		},
		props: {
			isSelect: {
				type:Number,
				default: 0
			},
			likeCount: {
				type:Number,
				default: 0
			},
			articleType: {
				type:Number,
				default: 1
			},
			articleId: {
				type:Number,
				default: 1
			},
		},
		watch:{
			isSelect(e){
				this.isSelectData = e
			},
			likeCount(e){
				this.nowlikeCount = e
			},
		},
		methods:{
			async likeAdaptiveFun(){
				await likeAdaptive({
					type:this.articleType,
					extend_id:this.articleId
				})
				
				this.isSelectData = this.isSelectData == 1?0:1;
				this.nowlikeCount = this.isSelectData == 1?this.nowlikeCount + 1:this.nowlikeCount - 1
			}
		}
	}
</script>

<style>
</style>